package com.sann.cms.controller;

import com.sann.cms.entity.Banner;
import com.sann.cms.service.BannerService;
import com.sann.common.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "网站首页Banner列表")
@RestController
@RequestMapping(path = "/cmsservice/banner/front")
@CrossOrigin
public class BannerFrontController {

    @Autowired
    private BannerService bannerService;

    @ApiOperation(value = "获取首页Banner")
    @GetMapping("/getList")
    public R getList(){
        List<Banner> list = null;
        try {
            list = this.bannerService.getList();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return R.ok().data("list", list);
    }
}
